//
//  LHYDefine.h
//  DrawLine
//
//  Created by lhy on 2021/2/5.
//

#ifndef LHYDefine_h
#define LHYDefine_h

#ifdef DEBUG
#define NSLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);
#else
#define NSLog(format, ...)
#endif

#pragma mark - RGB颜色

#define UIColorFromRGB(rgbValue)                    [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
//颜色
#define LHY_COLOR(r, g, b, a)                       [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
//随机色
#define LHY_RandomColor                             LHY_Color(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255), 1.0)
//微下载
#define MicroDownload               @"https://url.cn/5ug919c"
//启动广告
#define URL_AD                      @"https://api.shopping-shanghai.com/api/v1/advertising"

//-------------------Weak & Strong----------------------
#pragma mark - 解决循环应用相关

#define Weak(var, weakVar) __weak __typeof(&*var) weakVar = var
#define Strong_DoNotCheckNil(weakVar, _var) __typeof(&*weakVar) _var = weakVar
#define Strong(weakVar, _var)       Strong_DoNotCheckNil(weakVar, _var); if (!_var) return;

#define Weak_(var)                  Weak(var, weak_##var);
#define Strong_(var)                Strong(weak_##var, _##var);
#define WeakSelf                    Weak(self, weakSelf);
#define StrongSelf                  Strong(weakSelf, strongSelf);

//-------------------获取设备大小-------------------------
#pragma mark - 获取屏幕 宽度、高度

#define kScreenWidth                              ([UIScreen mainScreen].bounds.size.width)
#define kScreenHeight                             ([UIScreen mainScreen].bounds.size.height)

#define ViewX(v)                                      v.frame.origin.x
#define ViewY(v)                                      v.frame.origin.y
#define ViewW(v)                                      v.frame.size.width
#define ViewH(v)                                      v.frame.size.height
#define ViewXW(v)                                     ViewX(v) + ViewW(v)
#define ViewYH(v)                                     ViewY(v) + ViewY(v)

#define WIDTHRADIUS                                   SCREEN_WIDTH / 375.0
#define LHY_SPACE                                     25

#define kIs_iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define kIs_iPhoneX kScreenWidth >=375.0f && kScreenHeight >=812.0f&& kIs_iphone

/*状态栏高度*/
#define kStatusBarHeight (CGFloat)(kIs_iPhoneX?(44.0):(20.0))
/*导航栏高度*/
#define kNavBarHeight (44)
/*状态栏和导航栏总高度*/
#define kNavBarAndStatusBarHeight (CGFloat)(kIs_iPhoneX?(88.0):(64.0))
/*TabBar高度*/
#define kTabBarHeight (CGFloat)(kIs_iPhoneX?(49.0 + 34.0):(49.0))
/*顶部安全区域远离高度*/
#define kTopBarSafeHeight (CGFloat)(kIs_iPhoneX?(44.0):(0))
 /*底部安全区域远离高度*/
#define kBottomSafeHeight (CGFloat)(kIs_iPhoneX?(34.0):(0))
/*iPhoneX的状态栏高度差值*/
#define kTopBarDifHeight (CGFloat)(kIs_iPhoneX?(24.0):(0))
/*导航条和Tabbar总高度*/
#define kNavAndTabHeight (kNavBarAndStatusBarHeight + kTabBarHeight)
//----------------------系统----------------------------
//获取系统版本
#define IOS_VERSION                                   [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion                          [[UIDevice currentDevice] systemVersion]

//获取当前语言
#define CurrentLanguage                               ([[NSLocale preferredLanguages] objectAtIndex:0])

//当前应用的版本号
#define CurrentAppVersion                             [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//获取应用名称
#define APP_NAME                                      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]

//设置 view 圆角和边框
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

//获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//主要单例
#define UserDefaults                                [NSUserDefaults standardUserDefaults]
//沙盒存储
#define UserDefaultsPlayInAllNet                    @"UserDefaultsPlayInAllNet" //网络状态
#define UserDefaultsIsDark                          @"UserDefaultsIsDark"       //暗黑模式
#define IsNotFirstOpen                              @"IsNotFirstOpen"           //不是第一次打开

#define SharedApplication                           [UIApplication sharedApplication]
#define Bundle                                      [NSBundle mainBundle]
#define MainScreen                                  [UIScreen mainScreen]

//>>>>>>>>>>>>>>>>>>>>>字符串判定
#define IsNilString(__String)       (__String == nil || [__String isEqualToString:@""] || [__String isEqualToString:@"null"] || [__String isEqualToString:@"<null>"] || [__String isEqualToString:@"(null)"])

#define IsNotNilArr(arr)            (arr != nil && ![arr isKindOfClass:[NSNull class]] && arr.count != 0)
//----------------------图片----------------------------
//定义UIImage对象
#define ImageNamed(fileName)        [UIImage imageNamed:fileName]
#define LHYPlaceholderImage         ImageNamed(@"placeholder")
//普通
#define FONT(F)                     [UIFont systemFontOfSize:F]
//黑体
#define FONT_BOLD(F)                [UIFont boldSystemFontOfSize:F]
//设置View的tag属性
#define VIEWWITHTAG(_OBJECT, _TAG)  [_OBJECT viewWithTag : _TAG]
//由角度获取弧度 有弧度获取角度
#define DegreesToRadian(x)          (M_PI * (x) / 180.0)
#define RadianToDegrees(radian)     (radian * 180.0) / (M_PI)
//获取字典的key对应的String value
#define DSStringValue(x) x == nil ? @"" : x






#endif /* LHYDefine_h */
